package com.example.cwproject.mapper;

import com.example.cwproject.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    @Insert("insert into `user` (userName,email,password,signature,avatar) " +
            "values (#{userName},#{email},#{password},#{signature},#{avatar})")
    void insert(User user);

    //只修改个人信息
    @Update("update `user` set userName=#{userName}, " +
            "signature=#{signature} where email = #{email}")
    void update(User user);

    //修改密码
    @Update("update `user` set password=#{password} where email = #{email}")
    void modifyPassword(String password, String email);

    //上传头像
    @Update("update `user` set avatar = #{fileName} where email = #{email}")
    void uploadAvatar(String fileName, String email);


    @Select("select * from `user` where email = #{email};")
    User selectReturnUser(String email);

    @Select("select password from `user` where email = #{email};")
    String selectReturnPassword(String email);

    @Select("select * from `user` where email = #{email}")
    User selectUserByEmail(String email);
}
